package com.ep.instruktor.harmonogram;

import java.util.List;

import org.hibernate.SQLQuery;

import com.ep.general.GeneralClassMdt;
import com.ep.instruktor.harmonogram.db.HarmonogramKursant;

public class HarmonogramKursantMdt extends GeneralClassMdt<HarmonogramKursant> {

	public HarmonogramKursantMdt() {
		super(HarmonogramKursant.class);
	}

	@SuppressWarnings("unchecked")
	public List<HarmonogramKursant> getList(int harmonogramId) {
		getSession().beginTransaction();
		StringBuilder sql = new StringBuilder();
		sql.append("SELECT * FROM i_d_harmonogram_kursant");
		sql.append(" WHERE d_harmonogram_kursu_id =");
		sql.append(harmonogramId);

		SQLQuery query = getSession().createSQLQuery(sql.toString());
		query.addEntity(HarmonogramKursant.class);

		List<HarmonogramKursant> result = query.list();
		getSession().getTransaction().commit();

		return result;
	}
}
